package com.zg.common.core.dao.apis.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.common.core.dao.apis.entity.ApiInfo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author Zxb
 */
@Mapper
public interface ApiInfoMapper extends BaseMapper<ApiInfo> {

    @Select("<script>"+
            " SELECT info.*,service.service_name,project.project_name,category.category_name FROM api_info info LEFT JOIN api_category category ON info.category_id = category.id " +
            " left join api_service service on service.id = info.service_id "+
            " left join api_project project on project.id = service.project_id "+
            "<where>" +
            "  info.is_del = 0" +
            "  <if test=\"ew != null and ew.sqlSegment != ''\"> AND ${ew.sqlSegment}</if>" +
            "</where>" +
             "</script>")
    Page<ApiInfo> page(Page<ApiInfo> page,
                                   @Param(Constants.WRAPPER) LambdaQueryWrapper<ApiInfo> wrapper);
}
